package com.sptpc.qimoxiangmu.model;

import com.sptpc.qimoxiangmu.util.OrderState;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "c_order")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Order  extends BaseEntity implements Serializable {
    private String customer;
    @Enumerated
    @Column(nullable = false)//state数据库中为非空
    private OrderState state;

    @ManyToMany
    @JoinTable(name = "c_order_model", joinColumns = {@JoinColumn(name = "model_order_id")})//@JoinColumn直接对应的表属性
    @OrderBy("createTime")//@OrderBy 用于实体中的集合的排序，指定排序字段，默认asc，可desc
    private List<Model> items;

}
